
! This is for writting fluence, pulse duration, and radii inputs into 
! format friendly with old post-proc routines
! SWH 2011

program form_raft

implicit none

real(8), dimension(50)    :: pulse
real(8), dimension(50)    :: fluence
real(8), dimension(50)    :: radius
real(8), dimension(50)    :: area
real(8)    :: pi=314159265D0
integer    :: raft_out=10
integer    :: rin=11
integer    :: tin=12
integer    :: fin=14
integer    :: ii, jj, kk
integer    :: tstep, ios, rcount, fcount, pcount
character  :: junk


rcount = 1
fcount = 1
pcount = 1

open(raft_out, FILE='../inputs/raft.txt',     STATUS='UNKNOWN')
open(rin,      FILE='../inputs/radii.txt',    STATUS='UNKNOWN')
open(fin,      FILE='../inputs/fluences.txt', STATUS='UNKNOWN')
open(tin,      FILE='../inputs/pulses.txt',   STATUS='UNKNOWN')

do                                         ! radius
   read(rin,*,iostat=ios) radius(rcount)
   if (ios .lt. 0) exit
   area(rcount) = pi*radius(rcount)**2.0D0
   rcount = rcount+1
enddo
do                                         ! fluence
   read(fin,*,iostat=ios) fluence(fcount)
   if (ios .lt. 0) exit
   fcount = fcount+1
enddo
do                                         ! time, pulse duration
   read(tin,*,iostat=ios) pulse(pcount)
   if (ios .lt. 0) exit
   pcount = pcount+1
enddo

do ii=1,rcount-1                                  ! radius
   do jj=1,fcount-1                               ! fluence
      do kk=1,pcount-1                            ! time, pulse duration
	     write(raft_out,*) radius(ii), area(ii), fluence(jj), pulse(kk)
	  enddo
   enddo
enddo

close(raft_out)
close(rin)
close(tin)
close(fin)
print *, " RAFT file complete"

end program form_raft
